<?php
session_start();

require_once 'bd_connect.php';

$full_name = $_POST['full_name'];
$login = $_POST['login'];
$email = $_POST['email'];
$password = $_POST['password'];
$password_confirm = $_POST['password_confirm'];

if ($password === $password_confirm) {
    $password = md5($password);
    echo $password;


    $path = 'uoloads/' . time() . $_FILES['avatar']['name'];
    if (!move_uploaded_file($_FILES['avatar']['tmp'], '../' . $path))
    {
        $_SESSION['message'] = 'Ошибка при загрузке изображения';
        header('location: ../registr.php');
    }
    $sql = "INSERT INTO `users` (`id`, `full_name`, `login`, `email`, `avatar`, `password`) VALUES (NULL, '$full_name', '$login', '$email', '$path', '$password')";
    mysqli_query($connect, $sql);
    $_SESSION['message'] = 'Регистрация прошла успешно';
    header('location: ../index.php');
} else {
    $_SESSION['message'] = 'Пароли не совпадают';
    header('location: ../registr.php');
}